/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.dtgenerator.config;

import com.inspur.edp.bef.dtgenerator.BEGeneratorContext;
import com.inspur.edp.bef.dtgenerator.DotNetToJavaStringHelper;
import com.inspur.edp.cef.generator.configGenerator.CefConfigGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.CefCoreGeneratorContext;
import com.inspur.edp.das.commonmodel.IGspCommonModel;

public class BefConfigGenerator extends CefConfigGenerator {

	//  public static final String ConfigFileName = BefConfigUtils.defaultConfigName;

	public BefConfigGenerator(BEGeneratorContext beGenCtx) {
		super(beGenCtx);
	}

	public static String getBefConfigId(IGspCommonModel model) {
		return model.getGeneratedConfigID();
	}

	public static String getBefDotnetConfigId(IGspCommonModel model) {
		return model.getDotnetGeneratedConfigID();
	}

	private static String getDefaultNamespace(String metadataNamespace) {
		return metadataNamespace + ".core";
	}

	public BEGeneratorContext getBeGenCtx() {
		return (BEGeneratorContext) super.genCtx;
	}

	@Override
	protected String getApiAssemblyName() {
		return getBeGenCtx().getApiGenContext().getPackageName();
	}

	@Override
	protected String getCoreAssemblyName() {
		return ((CefCoreGeneratorContext) getBeGenCtx().getCoreGenContext()).getAssemblyName();
	}

	@Override
	protected String getConfigFileName() {
		return null;
	}

	@Override
	public String getConfigID() {
		return getBefConfigId(getBeGenCtx().getBE());
	}

	@Override
	protected String getDotnetConfigID() {
		return getBefDotnetConfigId(getBeGenCtx().getBE());
	}

	@Override
	public String getBEID() {
		return getBeGenCtx().getBE().getID();
	}

	@Override
	protected String getSourceID() {
		return !DotNetToJavaStringHelper.isNullOrEmpty(getBeGenCtx().getBE().getDependentEntityId())
				? getBefConfigId(getBeGenCtx().getParentBE())
				: "";
	}

	@Override
	protected String getDefaultNamespace() {
		return getDefaultNamespace(getBeGenCtx().getDataTypeNamespace());
	}
}
